from pydantic import BaseModel
from datetime import datetime

from forward.schema_base import EmptyStrToNone
from forward.utils.tools import ToolsUtil


class SalesmanSchema(BaseModel):
    name: str | None = None
    phone: str | None = None
    status: int | None = None
    entry_time: datetime | None = None
    resignation_time: datetime | None = None
    model_config = {
        "alias_generator": ToolsUtil.to_lower_camel,
        "populate_by_name": True,
    }


class SalesmanAddInSchema(SalesmanSchema):
    pass


class SalesmanOutSchema(SalesmanSchema):
    id: int
    created_time: datetime | None = None


class SalesmanEditInSchema(SalesmanSchema):
    id: int


class SalesmanStatusInSchema(BaseModel):
    id:int
    status: int


class SalesmanListInSchema(BaseModel):
    name: str | None = None
    phone: str | None = None
    status: int | None | EmptyStrToNone = None
    entry_time: datetime | None | EmptyStrToNone = None
    resignation_time: datetime | None | EmptyStrToNone = None
    page_no: int = 1
    page_size: int = 15
    model_config = {
        "alias_generator": ToolsUtil.to_lower_camel,
        "populate_by_name": True,
    }


class SalesmanDetailInSchema(BaseModel):
    id: int


class SalesmanDeleteInSchema(BaseModel):
    id: int
